package com.day04;

import java.util.Scanner;

/**
 * 从键盘读入个数不确定的整数，并判断读入的正数和负数的个数，输入为0时为结束程序
 */
public class ForWhileTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int positiveNumber = 0; //记录正数个数
        int negativeNumber = 0; //记录负数个数
        while (true) {
            int number = scanner.nextInt();


            if (0 == number) {
                //一旦执行break跳出循环
                break;
            } else if (0 < number) {
                positiveNumber++;
            } else {
                negativeNumber++;
            }
        }
        System.out.println("正数个数=" + positiveNumber + "负数个数=" + negativeNumber);

        //同上
        for (; ; ) {

            int number = scanner.nextInt();


            if (0 == number) {
                //一旦执行break跳出循环
                break;
            } else if (0 < number) {
                positiveNumber++;
            } else {
                negativeNumber++;
            }

            System.out.println("正数个数=" + positiveNumber + "负数个数=" + negativeNumber);
        }
    }
}
